/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hanze.shoestring.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alex
 */
@Entity
@Table(name = "medewerker")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Medewerker.findAll", query = "SELECT m FROM Medewerker m"),
    @NamedQuery(name = "Medewerker.findById", query = "SELECT m FROM Medewerker m WHERE m.id = :id"),
    @NamedQuery(name = "Medewerker.findByDatumIndienst", query = "SELECT m FROM Medewerker m WHERE m.datumIndienst = :datumIndienst"),
    @NamedQuery(name = "Medewerker.findByDatumUitdienst", query = "SELECT m FROM Medewerker m WHERE m.datumUitdienst = :datumUitdienst"),
    @NamedQuery(name = "Medewerker.findBySalaris", query = "SELECT m FROM Medewerker m WHERE m.salaris = :salaris"),
    @NamedQuery(name = "Medewerker.findByGids", query = "SELECT m FROM Medewerker m WHERE m.gids = :gids")})
public class Medewerker implements Serializable, Comparable {

    @Basic(optional = false)
    @NotNull
    @Column(name = "datum_indienst")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datumIndienst;
    @Column(name = "datum_uitdienst")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datumUitdienst;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "salaris")
    private float salaris;
    @Basic(optional = false)
    @NotNull
    @Column(name = "gids")
    private boolean gids;
    @JoinColumn(name = "persoon_id", referencedColumnName = "id")
    @OneToOne(cascade = CascadeType.PERSIST, optional = false)
    private Persoon persoon;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gidsId")
    private List<Planning> planningList;

    public Medewerker() {
    }

    public Medewerker(Integer id) {
        this.id = id;
    }

    public Medewerker(Integer id, Date datumIndienst, float salaris, boolean gids) {
        this.id = id;
        this.datumIndienst = datumIndienst;
        this.salaris = salaris;
        this.gids = gids;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDatumIndienst() {
        return datumIndienst;
    }

    public void setDatumIndienst(Date datumIndienst) {
        this.datumIndienst = datumIndienst;
    }

    public Date getDatumUitdienst() {
        return datumUitdienst;
    }

    public void setDatumUitdienst(Date datumUitdienst) {
        this.datumUitdienst = datumUitdienst;
    }

    public float getSalaris() {
        return salaris;
    }

    public void setSalaris(float salaris) {
        this.salaris = salaris;
    }

    public boolean getGids() {
        return gids;
    }

    public void setGids(boolean gids) {
        this.gids = gids;
    }

    public Persoon getPersoon() {
        return persoon;
    }

    public void setPersoon(Persoon persoon) {
        this.persoon = persoon;
    }

    @XmlTransient
    public List<Planning> getPlanningList() {
        return planningList;
    }

    public void setPlanningList(List<Planning> planningList) {
        this.planningList = planningList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Medewerker)) {
            return false;
        }
        Medewerker other = (Medewerker) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getPersoon().getAchternaam();
    }

    @Override
    public int compareTo(Object o) {
        Medewerker other = (Medewerker) o;
        return this.getPersoon().compareTo(other.getPersoon());
    }
}
